﻿using System.Web.Mvc;
using System.Web.Routing;
using EBE.COM.Core.Models;

namespace EBE.COM.Web.Areas.Admin.Controllers
{
  public class LoginController : ControllerBase
  {
    [HttpGet]
    public ActionResult Index()
    {
      return View();
    }

    [HttpPost]
    public ActionResult Index(string username, string password)
    {
      LoggedUser = GetUser(username, password);
      if (LoggedUser == null)
        return View();
      return RedirectToAction("Index", "Home");
    }

    private static User GetUser(string username, string password)
    {
      if (username == "mattia.richetto" && password == "t3st")
        return new User { Id = 101, Username = username };
      return null;
    }
  }
}
